import java.util.*;
	
public class example {
	public static void main(String[] args) {

		Collection<String> lst = new ArrayList<String>();
		
		String buf = "";
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < Math.floor(Math.random() * 30); j++) {
				buf = buf + (char) (Math.random() * 26 + 'a');
				;
			}
			lst.add(buf + "@" + buf + ".com");
			buf = "";
			if (i % 2 == 0) {
				lst.add(Math.random() + "sdfsdfsdf" + Math.random());
			}
		}
		CollectExample.showList(lst);
		System.out.println("===================================================================");
		new CollectExample(lst);
		CollectExample.showList(lst);

	}
}	
	class CollectExample {
	CollectExample(Collection<String> lst){
		Iterator<String> it = lst.iterator();
		while(it.hasNext()){
			if(!checkLine((String)it.next())){it.remove();}
		}
	}
	
	private boolean checkLine(String line){
		if(line.matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")){
			return true;
		}
		return false;
	}
	
	public static void showList(Collection<String> lst){
		Collections.shuffle((List<String>)lst);
		 Iterator<String> it = lst.iterator();
		 while(it.hasNext()){
			 System.out.println((String)it.next());
		 }
	}
}	

